
// 初始化发票寄送信息页面
function initSendInvoicePage(sendInvoiceType){
	if (sendInvoiceType==0){
		$("#sendInvoiceForm").find("input[name=sendInvoiceType][value="+sendInvoiceType+"]").attr("checked","checked");
		
		$("#expressSendInvoice").css("display", "block");
		$("#takeSendInvoice").css("display", "none");
	}else if (sendInvoiceType==1) {
		$("#sendInvoiceForm").find("input[name=sendInvoiceType][value="+sendInvoiceType+"]").attr("checked","checked");
		
		$("#expressSendInvoice").css("display", "none");
		$("#takeSendInvoice").css("display", "block");
	}else{
		$("#sendInvoiceForm").find("input[name=sendInvoiceType][value=0]").attr("checked","checked");
		
		$("#expressSendInvoice").css("display", "block");
		$("#takeSendInvoice").css("display", "none");
	}
	setupLabel();
}

// 隐藏修改弹框
function hideEdit() {
	$(".zhy_zhezhao_pop").hide();
	$(".zhy_popa").hide();
}

// 取消发票发送填写
function cancelSendInvoice() {
	var sendInvoiceType = $("#sendInvoiceForm input:radio:checked").attr("value");
	if (sendInvoiceType == "0"){
		$("#sendInvoiceForm button[name=expressCompanyMenu]").text("");
		$("#sendInvoiceForm input[name=expressNumber]").val("");
		
	}else{
		$("#sendInvoiceForm #takeSendInvoice").css("display", "none");
		$("#sendInvoiceForm input[name=takeInvoicePerson]").val("");
		$("#sendInvoiceForm input[name=contactPhone]").val("");
	}
				
	hideEdit();
}

// 改变发票发送类型
function changeSendType(obj) {
	var sendInvoiceType = $(obj).attr("value");
	if (sendInvoiceType==0){		
		$("#expressSendInvoice").css("display", "block");
		$("#takeSendInvoice").css("display", "none");
	}else if (sendInvoiceType==1) {
		$("#expressSendInvoice").css("display", "none");
		$("#takeSendInvoice").css("display", "block");
	}else{		
		$("#expressSendInvoice").css("display", "block");
		$("#takeSendInvoice").css("display", "none");
	}
	setupLabel();
}

// 提交表单
function submitSendInvoice(){
	var expressCompany = $("#sendInvoiceForm button[name=expressCompanyMenu]").attr("value");
	$("#sendInvoiceForm input[name=expressCompany]").val(expressCompany)

	var sendInvoiceType = $("#sendInvoiceForm input:radio:checked").attr("value");
	if (sendInvoiceType=="0"){
		if (expressCompany == "" || expressCompany==null){
			zhyAlert("请选择快递公司");
			return false;
		}
	}
		
	var invoiceType = $("#sendInvoiceForm button[name=invoiceTypeMenu]").attr("value");
	$("#sendInvoiceForm input[name=invoiceType]").val(invoiceType)
	
	if (invoiceType == "" || invoiceType==null){
		zhyAlert("请选择发票类型");
		return false;
	}
		
	$("#sendInvoiceForm").submit();
}